package com.dongdongshop.front.mongdb;

import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;

import java.time.LocalDateTime;
import java.util.Date;

/**
 * 文章评论实体类
 */
//把一个java 类 声明为 mongodb的文档 ， 可以通过 collection 参数 指定这个类对应的文档
@Document(collection = "article") // 可以省略默认使用类名小写映射集合
public class Article {

    //主键标识 该属性的值会自动对应mongodb的主键字段"_id",如果该属性名就叫id 该注解可以省略，否则必须写
    @Id
    private String id; // 主键

    //该属性对应mongodb字段属性的名字，如果一致，则无需注解
    @Field("content")
    private String content;//吐槽内容

    private Date publishtime;//发布时间

    // 添加一个字段为索引
    @Indexed
    private String userId;//发布人id

    private String nickName; // 昵称

    private LocalDateTime createdateTime;//评论的时间日期

    private Integer likenum;//点赞数

    private Integer replynum; //回复数

    private String state;//状态

    private String parentid;//上级id

    private String articleid;

    @Override
    public String toString() {
        return "Article{" +
                "id='" + id + '\'' +
                ", content='" + content + '\'' +
                ", publishtime=" + publishtime +
                ", userId='" + userId + '\'' +
                ", nickName='" + nickName + '\'' +
                ", createdateTime=" + createdateTime +
                ", likenum=" + likenum +
                ", replynum=" + replynum +
                ", state='" + state + '\'' +
                ", parentid='" + parentid + '\'' +
                ", articleid='" + articleid + '\'' +
                '}';
    }

    public Article() {
    }

    public Article(String id, String content, Date publishtime, String userId, String nickName, LocalDateTime createdateTime, Integer likenum, Integer replynum, String state, String parentid, String articleid) {
        this.id = id;
        this.content = content;
        this.publishtime = publishtime;
        this.userId = userId;
        this.nickName = nickName;
        this.createdateTime = createdateTime;
        this.likenum = likenum;
        this.replynum = replynum;
        this.state = state;
        this.parentid = parentid;
        this.articleid = articleid;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Date getPublishtime() {
        return publishtime;
    }

    public void setPublishtime(Date publishtime) {
        this.publishtime = publishtime;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    public LocalDateTime getCreatedateTime() {
        return createdateTime;
    }

    public void setCreatedateTime(LocalDateTime createdateTime) {
        this.createdateTime = createdateTime;
    }

    public Integer getLikenum() {
        return likenum;
    }

    public void setLikenum(Integer likenum) {
        this.likenum = likenum;
    }

    public Integer getReplynum() {
        return replynum;
    }

    public void setReplynum(Integer replynum) {
        this.replynum = replynum;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getParentid() {
        return parentid;
    }

    public void setParentid(String parentid) {
        this.parentid = parentid;
    }

    public String getArticleid() {
        return articleid;
    }

    public void setArticleid(String articleid) {
        this.articleid = articleid;
    }
}
